#ifndef _PLAYER_MGR_HPP_20120622
#define _PLAYER_MGR_HPP_20120622

#include "base.hpp"

#include "singleton.hpp"
#include "role_data.hpp"
#include "timer.hpp"
#include "cmd_all.hpp"

class Player;

struct LoginInfo
{
	ConnID          _conn_id;
	CSLoginReq      _req;
	Timer           _timer;
	uint32_t        _sequence;

	LoginInfo()
		: _conn_id(0),
		  _req(),
		  _timer(),
		  _sequence(0)
	{
	}
};

class PlayerMgr : public Singleton<PlayerMgr>
{
	public :
		typedef __gnu_cxx::hash_map<RID, LoginInfo> LoginInfoMap;
		typedef LoginInfoMap::iterator LoginInfoMap_Iter;
		
		typedef __gnu_cxx::hash_map<RID, Player*> PlayerMap;
		typedef PlayerMap::iterator PlayerMap_Iter;

	public :
		PlayerMgr();
		~PlayerMgr();

		Player * find_player(RID rid);

		template <typename _Req>
			int handle(Connection & conn, _Req & req)
			{
				return 0;
			}

		uint32_t sequence() { return (++ _sequence); }

	public :
		PlayerMap    _player_map;
		
		LoginInfoMap       _login_info_map;

		uint32_t           _sequence;

		DECL_LOGGER(logger);
};

#endif

